<template>

    <el-row>
        <el-col >
            <el-row class="el-heder">
                <el-col>
                    <h3>辉凡人力</h3>
                </el-col>
            </el-row>
            <el-form class="el-main">
                <el-form-item label="账号">
                    <el-input type="账号" v-model="formData.UserName" prop="usernam"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input type="password" v-model="formData.UserPassword" prop="password"></el-input>
                </el-form-item>
                <el-row>
                    <el-col>    
                        <el-form-item>
                    <el-checkbox v-model="formData.rememberMe">记住密码</el-checkbox>   
                    <el-link :underline="false" class="el-forgot">忘记密码</el-link>                              
                </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col>
                        <el-form-item>
                        <div>
                         </div>
                            <el-button type="primary" @click="submitForm" class="el-login">登录</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>             
            </el-form>
        </el-col>
    </el-row>
    </template>
  
  <script setup>
  import { ref } from 'vue';
  import axios from 'axios';
  import { useAxiosStore } from '../js/axiosStore';

  const axiosStore = useAxiosStore();
 
  const formData = ref({
    UserName: '',
    UserPassword: '',
  });
  

// 创建 axios 实例
const service = axios.create({
    baseURL: axiosStore.baseURL,
    timeout: 5000,
    headers: {
        'Content-Type': 'application/json'
    }
});
console.log('axios 实例配置:', service.defaults);

const submitForm = async () => {
   // 发送请求
   console.log('Form data:', formData.value);
service.post('api/Login/GetUser', {
    UserName: formData.value.UserName,
    UserPassword: formData.value.UserPassword
})
    .then(response => {
        console.log(response.data);
        ElMessage.success('验证通过，登录成功');
    })
    .catch(error => {
        console.log(error.response.data);
        ElMessage.error(error.response.data);
    });
};
  
 
  </script>
  
  <style scoped>
   
  </style>    